package com.jbm.core.client.remote;

import com.jbm.core.client.MainCallback;
import com.jbm.core.common.AccountCtrl;
import com.jbm.core.common.ConnectAgent;
import com.jbm.core.common.MainServer;
import com.jbm.core.iface.IAcross;
import com.jbm.core.iface.IP2P;

/**
 * Created by root on 17-2-28.
 */
public class RIP2P extends IP2P
{
	public RIP2P()
	{
	}

	public RIP2P(IAcross ia)
	{
		super(ia);
	}

	public IAcross ConnectP2P()
	{
		IP2P req = (IP2P)m_input;

		ConnectAgent ca = AccountCtrl.g_accountctrl.GetCA(req.m_fromer,req.m_msg);

		if ( ca == null )
			return new IAcross(404,"Not found CA");

		ca.ConnectP2P(false);

		return new IAcross(200,"OK");
	}

	public IAcross ArcossNAT()
	{
		return new IAcross(200,"OK");
	}

	public IAcross PushPoint ( )
	{
		IP2P p2p = (IP2P)m_input;

		MainCallback callback = MainServer.g_server.getM_maincallback();

		if ( callback != null )
		{
			callback.NewText(p2p.m_fromer,p2p.m_msg);
		}

		System.out.println("IP2P.PushPoint from:"+p2p.m_fromer+"msg:"+p2p.m_msg);

		return new IAcross(200,"PushOK");
	}
}
